<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel=StyleSheet HREF="../stylesheet/stylesheet.css" TYPE="text/css" MEDIA=screen>
<title>Shop Management System</title>
<?php include('menu.php'); ?>
<?php
include("../connect/connect.php");
?> 
<script>
function open_popup(){
	var sAll = document.getElementById('rdo1');
	var sSelect = document.getElementById('rdo2');
	var productname = document.getElementById('productname');
	var qty = document.getElementById('qty');


	if(sAll.checked == false && sSelect.checked == false){
		alert('กรุณาเลือกข้อมูลที่ต้องการพิมพ์บาร์โค้ดด้วยค่ะ');
		return false;
	}

	if(sSelect.checked == true && productname.value == ""){
		alert('กรุณาเลือกสินค้าที่ต้องการพิมพ์บาร์โค้ดด้วยค่ะ');
		return false;
	}

	if(sSelect.checked == true && productname.value != "" && qty.value == ""){
			alert('กรุณาระบุจำนวนด้วยค่ะ');
			qty.focus();
			return false;
	}

	document.formsearch.submit();
}
</script>
</head>
<body>
	<div class="box">
		<div class="left"></div>
		<div class="right"></div>
		<div class="heading">
			<h1>พิมพ์บาร์โค้ด</h1>
		</div>
		<div class="content">
		<br/>
<form action="barcodeform.php" name="formsearch" method="post" id="formsearch" target="_blank">
<table class="list2" width="370" border="0" align="center" cellpadding="7" cellspacing="0">
<thead>
	<tr>
		<td align="left"  style="padding: 10px;"><b>กรุณาเลือก</b></td>
		<td>&nbsp;</td>
	</tr>
</thead>
	<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td width="90" style="padding-left: 20px;"><label><input name="select" type="radio" value="all" id="rdo1" /> ทั้งหมด</label></td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td style="padding-left: 20px;"><label><input name="select" type="radio" value="listname" id="rdo2" /> เลือกตามชื่อ</label></td>
		<td align="left">
		<select name="productname" id="productname" style="width:150px;" onclick="JavaScript:document.formsearch.select[1].checked=true">
		<option value=""><----กรุณาเลือก----></option>
		<?php 
		$Query = mysql_query("SELECT code,name FROM product ORDER BY name");
		while($Row = mysql_fetch_array($Query)){
		?>
		<option value="<?php echo $Row['code'];?>"><?php echo $Row['name'];?></option>
		<?php } ?>
		</select> 
		จำนวน <input type="text" name="qty" id="qty" size="1" onKeyUp="IsNumeric(this.value,this)" maxlength="3" style="text-align: right;" onclick="JavaScript:document.formsearch.select[1].checked=true" /></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
	<tr>
		<td colspan="2" align="center"><div class="buttons"><a onclick="open_popup();" class="button"><span>แสดงบาร์โค้ด</span></a></div></td>
	</tr>
	<tr>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
	</tr>
</table>
</form>

		</div>
	</div>

</body>
</html>
